package net.message {

	import flash.utils.ByteArray;
	import flash.utils.IDataInput;
	
	import net.handler.IMessageHandler;

	public class BaseMessage {
		
		public var body:ByteArray;
		public var type:uint;
		public var handler:IMessageHandler;

		public function BaseMessage() {
			body = new ByteArray();
		}
		
		protected function readString(data:IDataInput):String {
			var length:uint = data.readInt();
			return data.readUTFBytes(length);
		}
		
		protected function readLong(data:IDataInput):String {
			var long:String = "";
			for (var i:int = 0; i < 8; i++) {
				long += data.readByte().toString(16);
			}
			return long;
		}
		
		public function readMessage(data:IDataInput):void {
			
		}
		
		public function writeMessage(data:IDataInput):void {
			
		}
		
		public function handlerMessage():void {
			if (handler != null) {
				handler.execute(this);
			}
		}
	}
}